import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '专业名称',
    align: 'left',
    dataIndex: 'typeName',
    width: "200px",
  },
  {
    title: '产业名称',
    align: 'center',
    dataIndex: 'nurseType_dictText'
  },
  // {
  //   title: '价格',
  //   align: 'center',
  //   dataIndex: 'price'
  // },
  {
    title: '单位',
    align: 'center',
    dataIndex: 'unit'
  },
  {
    title: '规格',
    align: 'center',
    dataIndex: 'specs',

  },
  {
    title: '分类图片',
    align: 'center',
    dataIndex: 'pic',
    customRender: render.renderImage,
  },
  {
    title: '商品详情',
    align: 'center',
    dataIndex: 'details'
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'sorts',
    sorter: true
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status_dictText'
  },
  // {
  //   title: '关联医院',
  //   align: 'center',
  //   dataIndex: 'hospital_dictText'
  // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "专业名称",
    field: "typeName",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "产业名称",
    field: "nurseType",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_type"
    },
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: "status",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "关联医院",
    field: "hospital",
    component: 'Input',
    componentProps: {
      disabled: true
    },
    defaultValue: "0"
    //colProps: {span: 6},
  },
  {
    label: "父级节点",
    field: "pid",
    component: 'Input',
    componentProps: {
      disabled: true
    },
    defaultValue: "1"
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '专业名称',
    field: 'typeName',
    component: 'Input',
  },
  {
    label: '产业名称',
    field: 'nurseType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_type"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入产业名称!' },
      ];
    },
  },
  // {
  //   label: '价格',
  //   field: 'price',
  //   component: 'Input',
  //   dynamicRules: ({ model, schema }) => {
  //     return [
  //       { required: true, message: '请输入价格!' },
  //     ];
  //   },
  // },
  {
    label: '单位',
    field: 'unit',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入单位!' },
      ];
    },
  },
  {
    label: '规格',
    field: 'specs',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入规格!' },
      ];
    },
  },
  {
    label: '分类图片',
    field: 'pic',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 5
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入分类图片!' },
      ];
    },
  },
  {
    label: '商品详情',
    field: 'details',
    component: 'InputTextArea',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入商品详情!' },
      ];
    },
  },
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "nurse_goods,type_name,id",
      pidField: "pid",
      pidValue: "1",
      hasChildField: "has_child",
    },
  },
  {
    label: '排序',
    field: 'sorts',
    component: 'InputNumber',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    defaultValue: "1",
    componentProps: {
      dictCode: "valid_status"
    },
  },
  // hospital 主键隐藏字段，目前写死为ID
  {
    label: '护理医院',
    field: 'hospital',
    component: 'Input',
    show: false
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  typeName: { title: '专业名称', order: 0, view: 'text', type: 'string', },
  nurseType: { title: '产业名称', order: 1, view: 'list', type: 'string', dictCode: 'nurse_type', },
  // price: { title: '价格', order: 2, view: 'number', type: 'number', },
  unit: { title: '计量单位', order: 3, view: 'text', type: 'string', },
  specs: { title: '规格', order: 4, view: 'text', type: 'string', },
  pic: { title: '分类图片', order: 5, view: 'image', type: 'string', },
  details: { title: '商品详情', order: 6, view: 'textarea', type: 'string', },
  sorts: { title: '排序', order: 8, view: 'text', type: 'string', },
  status: { title: '状态', order: 9, view: 'radio', type: 'string', },
};


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
